package com.blog.wl2023.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author wule
 * @desc 文章实体类
 */
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "messagelist")
@Data
public class MessageList extends BaseEntity {

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "user_id", referencedColumnName = "uuid")
	private User user;

	@Column(name = "create_time")
	private Date createTime;

	@Column(name = "message_content")
	private String messageContent;

	@Column(name = "is_delete")
	private Integer isDelete;


	/**
	 * 自定义字段,接收用户的头像
	 */
	@Transient
	private String imageUrl;

	@PrePersist
	public void prePersist() {
		this.createTime = new Date();
	}

}
